#ifndef DEPOT_H
#define DEPOT_H

#include <QObject>
#include <QStringList>
#include <QList>
#include <QStandardItem>
#include <QVariant>
#include <QMap>
#include "global/global.h"
#include "trade/tradehandler.h"
#include "db/db.h"
#include "config/config.h"
#include "depotconfig.h"

#define NO_FLAG         0x00
#define SET_BY_TRADE    0x01
#define STORE_DEPOT_STD_VALUES  0x02

class Depot:public TradeHandler,public DepotConfig
{
    Q_OBJECT
public:
    explicit Depot(const QString& name,const QStringList& standardValSymbols,QObject *parent=0);
    explicit Depot(const QString& name,const QStringList &standardValSymbols,const QStringList& standardValues, QObject *parent=0);
    explicit Depot(const QString& name,const QStringList &standardValSymbols,const QList<QVariant>& standardValues, QObject *parent=0);


    void setStandardValue(const QString& key,const QVariant& val,int flag=NO_FLAG);
    void setStandardValue(const QMap<QString,QVariant>& vals);

    void setStandardValues(const QMap<QString,QStandardItem*>& vals);
    QVariant getStandardValue(const QString& key);
    QMap<QString,QStandardItem*> getStandardValues()const;
    QMap<QString,QVariant> getStandardValuesVar();

    void setStocks(Stock *stocks);
    Stock* getStocks();



    double getCurrentLiquidity();
    void setCurrentLiquidity(const qreal& liq);

    Depot& operator =(const Depot&);

    void init(Config* cfg,int flag=NO_FLAG);

    void addStock(const QString &stockName);        //TODO: should be a stock symbol



signals:
    void standardValueChanged(const QString& depotName,const QString& standardValueField, const QString &value);

private:
    QMap<QString,QStandardItem*> standardVals;  //standard values of the depot, like depot liquidity
    Stock* stocks;                              //all stocks in the depot

    QMap<QString,QVariant> loadStdValues();
    QList<QMap<QString,QVariant> > loadDepotStocks();

};

#endif // DEPOT_H
